package com.JobWebGem.system.service.impl;

import com.JobWebGem.system.common.ErrorCode;
import com.JobWebGem.system.exception.BusinessException;
import com.JobWebGem.system.mapper.DeliveryMapper;
import com.JobWebGem.system.model.dto.delivery.DeliveryQueryRequest;
import com.JobWebGem.system.model.entity.Delivery;
import com.JobWebGem.system.model.vo.DeliveryVO;
import com.JobWebGem.system.service.DeliveryService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author renli
* @description 针对表【delivery(简历投递信息表)】的数据库操作Service实现
* @createDate 2024-12-03 13:47:17
*/
@Service
public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery>
    implements DeliveryService {

    @Resource
    private DeliveryMapper deliveryMapper;

    @Override
    public Page<DeliveryVO> listPage(Page<DeliveryVO> paramPage, DeliveryQueryRequest deliveryQueryRequest, Integer userId) {
        // 自定义分页查询
        List<DeliveryVO> deliveryVOS = deliveryMapper.getQueryByMy(paramPage, deliveryQueryRequest, userId);
        if (deliveryVOS != null) {
            paramPage.setRecords(deliveryVOS);
            return paramPage;
        } else {
            throw new BusinessException(ErrorCode.OPERATION_ERROR, "查询失败");
        }

    }

    @Override
    public Page<DeliveryVO> listPageByCompany(Page<DeliveryVO> paramPage, DeliveryQueryRequest deliveryQueryRequest, Integer companyId) {
        // 自定义分页查询
        List<DeliveryVO> deliveryVOS = deliveryMapper.getQueryByCompany(paramPage, deliveryQueryRequest, companyId);
        if (deliveryVOS != null) {
            paramPage.setRecords(deliveryVOS);
            return paramPage;
        } else {
            throw new BusinessException(ErrorCode.OPERATION_ERROR, "查询失败");
        }
    }
}




